class Solution1944 {
    public static void main(String[] args) {
        // int[] heights = {10,6,8,5,11,9};
        // int[] heights = {5,1,2,3,10};
        int[] heights = {100000,99998,99996,99994,99992,99991,99990};
        int[] res = Solution1944.canSeePersonsCount(heights);
    }

    public static int[] canSeePersonsCount(int[] heights) {
        int n = heights.length;
        int[] res = new int[n];
        res[n-2] = 1;

        int between_max, max_index;
        int i = 0;
        while (i < n-2) {
            if (res[i]==0){
                res[i]++;
                
                if (heights[i] >= heights[i+1]){
                    between_max = heights[i+1];
                    max_index = i+1;

                    for (int j = i+2; j < n; j++) {
                        if (heights[i] > between_max) {
                            if (heights[j] > between_max) {
                                res[i]++;
                                res[max_index] = j-max_index;
                                between_max = heights[j];
                                max_index = j;
                            }
                        }
                        if (heights[i] < heights[j])
                            break;
                    }
                }
            }
            i++;
        }
        return res;

    }
}